﻿<div class="panel panel-default">
    <div class="panel-heading">
        <h2 ng-if="!vm.isEditMode">{{::vm.translate.get('Create User')}}</h2>
        <h2 ng-if="vm.isEditMode">{{::vm.translate.get('Edit User')}}</h2>
    </div>
    <div class="panel-body">
        <form name="userForm" class="form-horizontal">
            <div class="col-sm-offset-2 bg-danger" ng-show="vm.validationErrors">
                <ul>
                    <li ng-repeat="error in vm.validationErrors">{{error}}</li>
                </ul>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('FullName')}}</label>
                <div class="col-sm-10">
                    <input name="name" ng-model="vm.user.fullName" class="form-control" />
                </div>
            </div>
            <div class="form-group" ng-if="!vm.isEditMode">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Password')}}</label>
                <div class="col-sm-10">
                    <input name="name" ng-model="vm.user.password" class="form-control" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Email')}}</label>
                <div class="col-sm-10">
                    <input name="email" ng-model="vm.user.email" class="form-control" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Phone Number')}}</label>
                <div class="col-sm-10">
                    <input name="description" ng-model="vm.user.phoneNumber" class="form-control" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Manager of Vendor')}}</label>
                <div class="col-sm-10">
                    <select class="form-control" ng-model="vm.user.vendorId" ng-options="vendor.id as vendor.name for vendor in vm.vendors">
                        <option value="">{{::vm.translate.get('Not Vendor')}}</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Roles')}}</label>
                <div class="col-sm-10">
                    <div class="checkbox" ng-repeat="role in vm.roles">
                        <label>
                            <input type="checkbox" ng-checked="vm.user.roleIds.indexOf(role.id) > -1" ng-click="vm.toggleRoles(role.id)"> {{role.name}}
                        </label>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Customer Groups')}}</label>
                <div class="col-sm-10">
                    <div class="checkbox" ng-repeat="customergroup in vm.customerGroups">
                        <label>
                            <input type="checkbox" ng-checked="vm.user.customerGroupIds.indexOf(customergroup.id) > -1" ng-click="vm.toggleCustomerGroups(customergroup.id)"> {{customergroup.name}}
                        </label>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button class="btn btn-primary" ng-click="vm.save()"><span class="glyphicon glyphicon-ok"></span> {{::vm.translate.get('Save')}}</button>
                    <button ui-sref="users" class="btn btn-default"> {{::vm.translate.get('Cancel')}}</button>
                </div>
            </div>
        </form>
    </div>
</div>